//
// Created by Orlando Chen on 2023/05/03.
//

#ifndef NETLINK_MULTIPLE_ADAPTERS_COMMON_H
#define NETLINK_MULTIPLE_ADAPTERS_COMMON_H

#include <linux/connector.h>
#include <string>

#ifdef CN_NETLINK_USERS
#undef CN_NETLINK_USERS
#define CN_NETLINK_USERS		11	/* Highest index + 1 */
#endif

#define CN_IDX_IWLAGN   (CN_NETLINK_USERS + 0xf)
#define CN_VAL_IWLAGN   0x1


extern "C" {

    /* Create a new netlink socket and bind it to the specified group_id */
    int create_netlink_socket(int group_id=-1);

    /* Create a client TCP socket */
    int create_tcp_client_socket(const std::string& server_ip, int port=8080);

    /* Create a server TCP socket */
    int create_tcp_server_socket(int port=8080);

    /* Exit the program */
    int exit_program_with_code(int code, std::string msg);

    /* Release the resources */
    int release_fd(int& fd);
};

#endif //NETLINK_MULTIPLE_ADAPTERS_COMMON_H
